﻿Imports System.IO

Public Class ValueTypesProvider
    Inherits TypeProvider
    Public Overrides ReadOnly Property Types As Type()
        Get
            Return {GetType(Byte),
                    GetType(Short),
                    GetType(Integer),
                    GetType(Long),
                    GetType(SByte),
                    GetType(UShort),
                    GetType(UInteger),
                    GetType(ULong),
                    GetType(Single),
                    GetType(Double),
                    GetType(Decimal)}
        End Get
    End Property
    Public Overrides Function ReadObject(T As Type) As Object
        Dim S = CTypeDynamic(Val(ReadBlock), T)
        Info.AddCache(S)
        Return S
    End Function
    Public Overrides Sub WriteObject(Obj As Object)
        Info.AddCache(Obj)
        Write(Obj.ToString)
    End Sub
End Class